package com.example.teachdemo05;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class SharedPreferencesActivity extends AppCompatActivity {

    EditText et_user;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shared_preferences);
        et_user = findViewById(R.id.et_user);
    }

    public void login(View view) {
        SharedPreferences preferences = getSharedPreferences("mydata",MODE_PRIVATE);

        SharedPreferences.Editor editor = preferences.edit();

        editor.putString("key_user",et_user.getText().toString());

        editor.commit();

        startActivity(new Intent(this,TestPreferenceActivity.class));

    }
}
